Polygons#
Download this notebook from GitHub (right-click to download).
import hvplot.pandas # noqa
Using hvplot with geopandas is as simple as loading a geopandas dataframe and calling hvplot on it with geo=True.
import geopandas as gpd
countries = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
countries.sample(5)
| pop_est | continent | name | iso_a3 | gdp_md_est | geometry | |
|---|---|---|---|---|---|---|
| 171 | 2103721 | Europe | Macedonia | MKD | 29520.0 | POLYGON ((22.38053 42.32026, 22.88137 41.99930... |
| 150 | 1972126 | Europe | Slovenia | SVN | 68350.0 | POLYGON ((13.80648 46.50931, 14.63247 46.43182... |
| 68 | 1772255 | Africa | Gabon | GAB | 35980.0 | POLYGON ((11.27645 2.26105, 11.75167 2.32676, ... |
| 36 | 9038741 | North America | Honduras | HND | 43190.0 | POLYGON ((-83.14722 14.99583, -83.48999 15.016... |
| 64 | 6163195 | Africa | Sierra Leone | SLE | 10640.0 | POLYGON ((-13.24655 8.90305, -12.71196 9.34271... |
countries.hvplot(geo=True)
Control the color of the elements using the c option.
countries.hvplot.polygons(geo=True, c='pop_est', hover_cols='all')
You can even color by another series, such as population density:
countries.hvplot.polygons(geo=True, c=countries.pop_est/countries.area, clabel='pop density')
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.
Download this notebook from GitHub (right-click to download).